import { defineStore } from "pinia";
import {currentRoute} from "@/config";
export default defineStore("routes", {
  state: () => ({
    routes: [],
    currentRoute: JSON.parse(localStorage.getItem(currentRoute)) || null,
    menuList: [],
  }),
  actions: {
    setRoutes(routes) {
      this.routes = routes;
    },
    setMenuList(routes) {
      this.menuList = routes;
    },
    initMenuList() {
      this.setMenuList(this.routes);
    },
    setCurrentRoute(route) {
      this.currentRoute = route;
      localStorage.setItem(currentRoute, JSON.stringify(this.currentRoute));
    },
  },
});
